package com.tang.javaSwingCaculate.CaculateGUI;

import javax.swing.*;
import java.awt.*;

/**
 * @author tmh
 * @date 2022/12/9 16:11
 * @description
 */
public class MyPanel {
    public static void main(String[] args) {
        //确保一个漂亮的外观风格
        JFrame.setDefaultLookAndFeelDecorated(true);
        //创建以及设置窗口
        JFrame jf = new JFrame("myTestSwing");
        jf.setSize(300, 300);
        jf.setLocationRelativeTo(null);
//        jf.setBounds(400, 400, 1000, 900);
        GridLayout gridLayout = new GridLayout();
//        jf.setLayout(gridLayout);//网格布局


        Container c = jf.getContentPane();
        c.setLayout(gridLayout);

        //面板一
        JPanel p1 = new JPanel();
        p1.setBorder(BorderFactory.createTitledBorder("p1"));
        p1.setBackground(Color.pink);
        c.add(p1);

        JPanel p2 = new JPanel();
        p1.setBorder(BorderFactory.createTitledBorder("p2"));
        p1.setBackground(Color.blue);
        c.add(p2);

        JPanel p3 = new JPanel();
        p1.setBorder(BorderFactory.createTitledBorder("p3"));
        p1.setBackground(Color.green);
        c.add(p3);

        JPanel p4 = new JPanel();
        p1.setBorder(BorderFactory.createTitledBorder("p4"));
        p1.setBackground(Color.red);
        c.add(p4);

        p1.setVisible(true);
        p2.setVisible(true);
        p3.setVisible(true);
        p4.setVisible(true);
        c.setVisible(true);
        jf.setVisible(true);
        jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }
}
